<template>
  <div class="app-container">
    <wise-crud ref="wise-crud" :urls="urls" :fields="fields" :handle="handle" :filters="filters" /></wise-crud></div>
</template>
<script>
import WiseCrud from '@/components/Crud/wiseCrud'
export default {
  name: 'PatrolManage',
  components: { WiseCrud },
  data() {
    return {
      urls: {
        list: '/api/v1/welder-sbtx-second/patrol-comb/list',
        add: '/api/v1/welder-sbtx-second/patrol-comb/create',
        show: '/api/v1/welder-sbtx-second/patrol-comb/show/',
        update: '/api/v1/welder-sbtx-second/patrol/update/',
        delete: '/api/v1/welder-sbtx-second/patrol/remove/'
      }
    }
  },
  computed: {
    spaceId() {
      return this.$store.state.project.spaceId
    },
    handle() {
      // if (this.$store.state.user.project) {
      //   return ['add']
      // } else {
      //   return ['add', 'filters']
      // }
      return ['add']
    },
    fields() {
      let arr = [{ label: '序号', type: 'index', use: ['table'] }]
      if (this.$store.state.user.project) {
        arr.push({
          prop: 'projectId',
          defaultValue: this.$store.state.user.project.id,
          use: ['add', 'edit']
        })
      } else {
        // arr.push({
        //   label: '所属项目',
        //   prop: 'projectInfo',
        //   type: 'select',
        //   labelWidth: '130px',
        //   url: '/api/v1/welder-sbtx-second/project-info',
        //   labelKey: 'name',
        //   valueKey: 'id',
        //   objKeys: [
        //     {
        //       field: 'projectId',
        //       key: 'id'
        //     }
        //   ],
        //   rules: [
        //     { required: true, message: '请选择项目', trigger: 'change' }
        //   ],
        //   placeholder: '请选择项目',
        //   use: ['add', 'edit', 'filters']
        // })
        // arr.push({
        //   label: '所属项目',
        //   prop: 'manage',
        //   type: 'render',
        //   labelWidth: '130px',
        //   tableRender: (h, row, index) => {
        //     return h('div', row.projectInfo ? row.projectInfo.name : '')
        //   },
        //   viewRender: (h, item, object) => {
        //     return h('div', object.projectInfo ? object.projectInfo.name : '')
        //   },
        //   use: ['table', 'view']
        // })
      }
      arr.push(
        {
          label: '巡检点位名称',
          prop: 'name',
          type: 'text',
          labelWidth: '130px',
          rules: [
            {
              required: true,
              message: '请输入巡检点位名称',
              trigger: 'change'
            }
          ],
          placeholder: '请输入巡检点位名称',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          label: '巡检点位状态',
          prop: 'status',
          type: 'radio',
          dataDic: 'patrolStatus',
          labelWidth: '130px',
          rules: [
            {
              required: true,
              message: '请选择巡检点位状态',
              trigger: 'change'
            }
          ],
          placeholder: '请选择巡检点位状态',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          label: '巡检时间',
          prop: 'time',
          type: 'datetime',
          format: 'YYYY-MM-DD HH:mm:ss',
          labelWidth: '130px',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          label: '描述',
          prop: 'content',
          type: 'text',
          labelWidth: '130px',
          rules: [{ required: true, message: '请输入描述', trigger: 'change' }],
          placeholder: '请输入描述',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          prop: 'spaceId',
          defaultValue: this.$store.state.project.spaceId,
          use: ['add', 'edit']
        }
      )
      arr.push({
        label: '操作',
        type: 'handle',
        use: ['table'],
        handle: ['edit', 'view', 'delete'],
        tableWidth: 300
      })
      return arr
    },
    filters() {
      return [
        {
          field: 'spaceId',
          operator: 'EQUALS',
          value: this.$store.state.project.spaceId
        }
      ]
    }
  },
  methods: {}
}
</script>

<style>
</style>
